from PIL import Image
import pytesseract

def recognize_text(image_path):
    """
    识别图片中的文字
    :param image_path: 图片路径
    :return: 识别出的文字
    """
    # 打开图片文件
    img = Image.open(image_path)
    # 使用pytesseract进行OCR识别
    text = pytesseract.image_to_string(img, lang='chi_sim+eng')
    return text

if __name__ == '__main__':
    # 示例用法
    image_path = 'example.png'  # 替换为你的图片路径
    result = recognize_text(image_path)
    print("识别结果:")
    print(result)